package com.acme;


import java.util.ArrayList;
import java.util.Date;


public class Bank  {
	
	//private final Client[] clients = new Client[10];
	private int maxClients = 0;
	//private ClientRegistrationListener[] listeners;
	private ArrayList<Client> clients;
	private ArrayList<ClientRegistrationListener> listeners;
	

	public Bank() {

	}
	
	public Bank(ClientRegistrationListener[] listeners) {
		this.listeners = new ArrayList<ClientRegistrationListener>();
		this.clients = new ArrayList<Client>();
		this.listeners = new ArrayList<ClientRegistrationListener>();

		class DebugListener implements ClientRegistrationListener { //create inner class
			public void onClientAdded(Client c) {
				System.out
						.println("Debug client info: " + c.getName()
								+ " created at "
								+ new Date(System.currentTimeMillis()));
			}
		}

		this.listeners.add(new DebugListener());//first add Debug Listener
		for (int i = 0; i < listeners.length; i++) {//then all others
			this.listeners.add(listeners[i]);
		}
	}
		 
	
	
	


public void addClient(Client client) {
	this.clients.add(client);
	for (int i = 0; i < listeners.size(); i++) {
		listeners.get(i).onClientAdded(client);
	}
}

public ArrayList<Client> getClients() {
	return this.clients;
}

	
	
	
	/*public Client addClient(final Client client) {
		clients[maxClients++] = client;
		
		for (int i =0; i < listeners.length; i++) {
			listeners[maxClients].onClientAdded(client);	
			
		}
		return client;
	}
*/

	public static void main(String[] args) {
		
		
	}
	
}
